From 857c4c908e11974af7b35434145708dabd93ac8c Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sun, 7 Jun 2020 10:56:18 -0600 Subject: [PATCH] fix Uncaught TypeError: map.checkResize is not a function (#593) * fix Uncaught TypeError: map.checkResize is not a function with GUI map preview. * remove extra newline from map preview javascript. * tighten up js generation. * tighten up js some more. * tweak js generation. --- gui/map.cc | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/gui/map.cc b/gui/map.cc index 1546a6c7e..a55c752e3 100644 --- a/gui/map.cc +++ b/gui/map.cc @@ -219,13 +219,12 @@ void Map::showGpxData() num = 0; foreach (const GpxTrack& trk, gpx_.getTracks()) { vector pts; - QString path; foreach (const GpxTrackSegment seg, trk.getTrackSegments()) { foreach (const GpxTrackPoint pt, seg.getTrackPoints()) { pts.push_back(pt.getLocation()); } } - path = makePath(pts); + QString path = makePath(pts); scriptStr << QString("trks[%1] = new RTPolyline(\n" @@ -249,11 +248,10 @@ void Map::showGpxData() num = 0; foreach (const GpxRoute& rte, gpx_.getRoutes()) { vector pts; - QString path; foreach (const GpxRoutePoint& pt, rte.getRoutePoints()) { pts.push_back(pt.getLocation()); } - path = makePath(pts); + QString path = makePath(pts); scriptStr << QString("rtes[%1] = new RTPolyline(\n" @@ -378,30 +376,20 @@ void Map::hideAllRoutes() //------------------------------------------------------------------------ void Map::setWaypointVisibility(int i, bool show) { - evaluateJS(QString("waypts[%1].setVisible(%2);\n") + evaluateJS(QString("waypts[%1].setVisible(%2);") .arg(i).arg(show?"true": "false")); } //------------------------------------------------------------------------ void Map::setTrackVisibility(int i, bool show) { - QString x = show?"show": "hide"; - QStringList scriptStr; - scriptStr - << QString("trks[%1].%2();").arg(i).arg(x) - ; - evaluateJS(scriptStr); + evaluateJS(QString("trks[%1].%2();").arg(i).arg(show?"show": "hide")); } //------------------------------------------------------------------------ void Map::setRouteVisibility(int i, bool show) { - QString x = show?"show": "hide"; - QStringList scriptStr; - scriptStr - << QString("rtes[%1].%2();").arg(i).arg(x) - ; - evaluateJS(scriptStr); + evaluateJS(QString("rtes[%1].%2();").arg(i).arg(show?"show": "hide")); } //------------------------------------------------------------------------ @@ -419,7 +407,7 @@ void Map::resizeEvent(QResizeEvent* ev) QWebView::resizeEvent(ev); #endif if (mapPresent_) { - evaluateJS(QString("map.checkResize();")); + evaluateJS(QString("google.maps.event.trigger(map, 'resize');")); } } @@ -465,8 +453,7 @@ void Map::frameRoute(int i) void Map::evaluateJS(const QString& s, bool upd) { #ifdef DEBUG_JS_GENERATION - *dbgout_ << s; - *dbgout_ << '\n'; + *dbgout_ << s << '\n'; dbgout_->flush(); #endif #if HAVE_WEBENGINE @@ -482,5 +469,5 @@ void Map::evaluateJS(const QString& s, bool upd) //------------------------------------------------------------------------ void Map::evaluateJS(const QStringList& s, bool upd) { - evaluateJS(s.join("\n"), upd); + evaluateJS(s.join('\n'), upd); } -- 2.30.2